package sw6.launcher;

import sw6.girafAppKit.GirafActivity;
import android.content.Intent;
import android.content.pm.ResolveInfo;
import android.os.Bundle;
import android.view.View;
import android.widget.AdapterView;
import android.widget.AdapterView.OnItemClickListener;
import android.widget.GridView;



public class launcher extends GirafActivity {
	protected final static String tag = "GIRAF"; 
	
	/** Called when the activity is first created. 
	 *  Populates the GridView and sets the onClickListner
	 */
	@Override
	public void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		this.setContentView(R.layout.main);
		
		GridView gridview = (GridView) findViewById(R.id.gridView);
	    gridview.setAdapter(new IconAdapter(this));

	    gridview.setOnItemClickListener(new OnItemClickListener() {
	        public void onItemClick(AdapterView<?> parent, View v, int position, long id) {
	        	Intent intent = new Intent("android.intent.action.MAIN");
                intent.addCategory("android.intent.category.LAUNCHER");
                
                ResolveInfo mInfo = (ResolveInfo)parent.getItemAtPosition(position);
                
                intent.setClassName(mInfo.activityInfo.packageName, mInfo.activityInfo.name);
                
                startActivity(intent);
	        }
	    });
		
	}
	
	/** Called when the activity is destroyed, but does nothing special here */
	public void onDestroy() {
		super.onDestroy();
	}
}